// Implement your views here using the SJS DSL.
external id:['restartModuleWithConfirmationFrontAction']

entityCardView('allEntities.cardView') {
	views {
		form(model:'Node')
		form(model:'Segment')
		border(parent:'Voyage.detail.view')
		form(model:'GpsLocation')
	}
}


actionMap('filterableBeanCollectionModuleActionMap', parents:['beanCollectionModuleActionMap']) {
	actionList('FILE') {
		action(ref:'queryModuleFilterAction')
	}
	actionList('TEST') {
		action(ref:'storeEntityAsTestEntity')
	}
}

border('Voyage.module.view', cascadingModels:true) {
	center {
		table(model:'Voyage', parent:'filterableBeanCollectionModuleView')
	}
	south {
		table(model:'Voyage-segments')
	}
}

border('Voyage.detail.view', model:'Voyage', borderType:'TITLED') {
	center {
		form(model:'Voyage')
	}
	south {
		table(model:'Voyage-segments', actionMap:'beanCollectionModuleActionMap')
	}
}

table('TestEntity.module.view', parent:'filterableBeanCollectionModuleView') {
	actionMap {
		actionList('TEST') {
			action(ref:'restartModuleFrontAction')
			action(ref:'queryModuleFilterAction')
			action(ref:'displayEntityFromTestEntity')
			action(ref:'switchToTestEnvironnement')
			action(ref:'switchToNormalEnvironnement')
		}
	}
}
border('BackActionTest.module.view', cascadingModels:true) {
	west {
		table(model:'BackActionTest', parent:'filterableBeanCollectionModuleView') {
			actionMap {
				actionList('persistenceBeanCollectionModuleActionList') {
					action ref:'restartModuleWithConfirmationFrontAction'
					action ref:'saveModuleObjectFrontAction'
					action ref:'reloadModuleObjectFrontAction'
					action ref:'queryModuleFilterAction'
				}
				actionList('detailBeanCollectionModuleActionList') {
					action ref:'addAsChildModuleFrontAction'
				}
				actionList('moduleMasterDetailActionList') {
					action ref:'addToMasterFrontAction'
					action ref:'removeFromModuleObjectsFrontAction'
				}
				actionList('EXECUTE') {
					action ref:'runSelectedBackActionTestFrontAction'
				}
			}
			columns {
				propertyView name:'description'
				propertyView name:'backendBeanName'
				referencePropertyView name:'testScope'
				referencePropertyView name:'nextAction'
				referencePropertyView name:'prevAction'
			}
		}
	}
	center {
		split_vertical(preferredHeight:400, model:'BackActionTest') {
			top {
				table(parent:'IoTable.view', model:'BackActionTest-inputs', itemSelectionAction:'switchModelForIoFormView')
			}
			bottom {
				table(parent:'IoTable.view', model:'BackActionTest-outputs', itemSelectionAction:'switchModelForIoFormView') {
					columns {
						propertyView name:'parameterKey'
						propertyView name:'description'
						propertyView name:'lastExecutionSuccessfull'
					}
				}

			}
		}
	}
	south {
		split_horizontal(left:'ActionTestIoTypeCarViewDescriptor', right:'ActionTestIoCarViewDescriptor')
	}
}

action('switchModelForIoFormView', parent:'switchModelForView', custom:[targetDescriptor_ref:'ActionTestIoTypeCarViewDescriptor']) {
	next(ref:'switchModelForIoDetailFormView')
}
action('switchModelForIoDetailFormView', parent:'switchModelForView', custom:[targetDescriptor_ref:'ActionTestIoCarViewDescriptor'])

table('IoTable.view', model:'ActionTestIo') {
	actionMap {
		actionList('masterDetailActionList') {
			action ref:'addToMasterFrontAction'
			action ref:'cloneEntityCollectionFrontAction'
			action ref:'removeEntityCollectionFromMasterFrontAction'
			action ref:'switchModelForIoFormView'
		}
	}
	columns {
		propertyView name:'parameterKey'
		propertyView name:'description'
	}
}

bean('ActionTestIoCarViewDescriptor', class:'org.jspresso.framework.view.descriptor.cardView.ActionTestIoCarViewDescriptor', custom:[defaultView_ref:'ActionTestIo.default.view'])
bean('ActionTestIoTypeCarViewDescriptor', class:'org.jspresso.framework.view.descriptor.cardView.ActionTestIoTypeCarViewDescriptor', custom:[defaultView_ref:'ActionTestIo.type.view'])

form('ActionTestIo.type.view', model:'ActionTestIo') {
	fields {
		propertyView name:'parameterType', action:'switchModelForIoDetailFormView'
		propertyView name:'ioType', action:'switchModelForIoDetailFormView'
		propertyView name:'sql', action:'switchModelForIoDetailFormView'
		propertyView name:'prevOutputAsSource', action:'switchModelForIoDetailFormView'
	}
}


border('ActionTestIo.default.view', model:'ActionTestIo') {
	center {
		form {
			fields {
				propertyView name:'parameterKey'
				propertyView name:'description'
				propertyView name:'prevOutputParameterKey'
				referencePropertyView name:'parameterRefValue', actionMap:'testEntityAffectationActionMap', lovAction:'chooseEntityForLovAction'
				//referencePropertyView name:'parameterRefValue', lovAction:'chooseEntityForLovAction'
				propertyView name:'parameterSqlValue'
			}
		}
	}
	south {
		table(model:'ActionTestIo-parameterRefValues') {
			actionMap {
				actionList('masterDetailActionList') {
					action parent:'chooseEntityForLovAction', enumActionabilityGates:['parameterType':['LIST']], icon:'classpath:org/jspresso/framework/application/images/find-48x48.png'
					action parent:'chooseEntityForCreationAction', enumActionabilityGates:['parameterType':['LIST']], icon:'classpath:org/jspresso/framework/application/images/edit_add-48x48.png'
					action parent:'chooseEntityToCloneAction', enumActionabilityGates:['parameterType':['LIST']], icon:'classpath:org/jspresso/framework/application/images/edit_clone-48x48.png'
					action parent:'removeTestEntityCollectionFrontAction', enumActionabilityGates:['parameterType':['LIST']], icon:'classpath:org/jspresso/framework/application/images/edit_remove-48x48.png'
					action parent:'moveUpFrontAction'
					action parent:'moveDownFrontAction'
					action parent:'moveTopFrontAction'
					action parent:'moveBottomFrontAction'
				}
			}
			columns {
				propertyView name:'displayable', action:'editTestEntityAction'
			}
		}
	}
}

actionMap('testEntityAffectationActionMap', validationModel:'ActionTestIo') {
	actionList('ACTIONS') {
		action (parent:'chooseEntityForCreationAction', icon:'classpath:org/jspresso/framework/application/images/edit_add-48x48.png')
		action (parent:'chooseEntityToCloneAction', icon:'classpath:org/jspresso/framework/application/images/edit_clone-48x48.png')
		action (parent:'editTestEntityAction', icon:'classpath:org/jspresso/framework/application/images/view-48x48.png', booleanActionabilityGates:['parameterRefValue.generatedEntity'])
	}
}

border('EntityDescriptorPicker.view') {
	center {
		table(permId:'EntityDescriptorPicker.view.EntityDescriptorPicker-descriptors.table', model:'EntityDescriptorPicker-descriptors', readOnly:true, selectionMode:'SINGLE_SELECTION')
	}
}

border('TestEntityPicker.view', model:'TestEntityPicker') {
	center {
		table(model:'TestEntityPicker-testEntities') {
			columns {
				propertyView name:'displayable'
			}
		}
	}
}

table('Repeater.module.view', parent:'filterableBeanCollectionModuleView', model:'Voyage') {
  actionMap {
    actionList('persistenceBeanCollectionModuleActionList') {
      action ref:'restartModuleWithConfirmationFrontAction'
      action ref:'saveModuleObjectFrontAction'
      action ref:'reloadModuleObjectFrontAction'
    }
    actionList('detailBeanCollectionModuleActionList') {
      action (parent:'addCollectionPropertyAsChildModuleFrontAction', custom:[childModuleProjectedViewDescriptor_ref:'formViewRepeater'])
    }
    actionList('moduleMasterDetailActionList') {
      action ref:'addToMasterFrontAction'
      action ref:'cloneEntityCollectionFrontAction'
      action ref:'removeFromModuleObjectsFrontAction'
    }
    actionList('FILE') {
      action ref:'queryModuleFilterAction'
    }
    actionList('TEST') {
      action ref:'storeEntityAsTestEntity'
    }
  }
}

form('Segment.detail.view', model:'Segment')
